<template>
    <div>

    </div>
</template>

<script>
    export default {
        name: "FaceLogin",
        data(){
            return{
                login: {
                    password: "",
                    username:'',
                },
            }
        },
        methods:{

            loginBtn() {
                this.axios
                    .post("http://localhost:9151/user/login", {
                        userName: this.login.username,
                        password: this.login.password,
                    })
                    .then((res) => {
                        if (res.data.code == 200) {
                            this.iconstyle = "el-icon-check";
                            this.btnType = "success";
                            this.$message({
                                message: "登录成功，正在跳转",
                                type: "success",
                            });
                            setTimeout(() => {
                                this.disabled = false;
                                this.$store.commit("setFind");
                                this.$router.push("/findroom");
                            }, 2000);
                        } else {
                            this.iconstyle = "el-icon-close";
                            this.btnType = "danger";
                            this.$message({
                                message: "登录失败，账号或密码错误",
                                type: "error",
                            });
                            setTimeout(() => {
                                this.disabled = false;
                                this.iconstyle = "iconfont icon-r-right";
                                this.btnType = "primary";
                            }, 2000);
                        }
                    })
                    .catch((e) => {
                        this.iconstyle = "el-icon-close";
                        this.btnType = "danger";
                        setTimeout(() => {
                            this.disabled = false;
                            this.iconstyle = "iconfont icon-r-right";
                            this.btnType = "primary";
                        }, 2000);

                        if (e.response == undefined || e.response.data == undefined) {
                            this.$message({
                                showClose: true,
                                message: e,
                                type: "error",
                                duration: 0,
                            });
                        } else {
                            this.$message({
                                showClose: true,
                                message: e.response.data,
                                type: "error",
                                duration: 0,
                            });
                        }
                    });
            },
        },
        created() {

        }
    }
</script>

<style scoped>

</style>
